using HDLogCenter.Dal.Repos;
using HDLogCenter.Infrastructure.Models;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace HDLogCenter.Bll.Services
{
    public class ProjectConfigService
    { 
        private readonly AppConfigRepo _appConfigRepo;

        public ProjectConfigService(AppConfigRepo appConfigRepo)
        {
            _appConfigRepo = appConfigRepo;
        }

        public async Task<IEnumerable<AppConfigModel>> GetAllProjectsAsync()
        {
            return await _appConfigRepo.GetAllAsync();
        }

        public async Task<AppConfigModel> GetProjectByIdAsync(long id)
        {
            return await _appConfigRepo.GetByIdAsync(id);
        }

        public async Task<AppConfigModel> GetProjectByAppCodeAsync(string appCode)
        {
            return await _appConfigRepo.GetByAppCodeAsync(appCode);
        }

        public async Task<long> CreateProjectAsync(AppConfigModel project)
        {
            var result = await _appConfigRepo.CreateAsync(project);
            return result ?? 0;
        }

        public async Task<bool> UpdateProjectAsync(AppConfigModel project)
        {
            return await _appConfigRepo.UpdateAsync(project);
        }

        public async Task<bool> DeleteProjectAsync(long id)
        {
            return await _appConfigRepo.DeleteAsync(id);
        }

    }
}
